import {createStore} from 'redux';
import methods from "./method";
import state from './state'
//初始化数据
let data = state;
//初始化state状态

//创建一个修改数据方法的对象
let ActionFnObj = methods;

const store = createStore(reduce);//创建一个数据仓库
//传进去的reduce是一个方法
function reduce(state=data,action){
  //console.log(state)
  //console.log(ActionFnObj)
 // console.log(action.type)
  if(action.type.indexOf('redux') === -1){
    state = ActionFnObj[action.type](state,action)
    return {...state}
  }
  else{
    return state
  }
}

export default store;